View Javadoc

1   // Delegates.java, created Mon Dec 23 20:00:01 2002 by mcmartin
2   // Copyright (C) 2001-3 mcmartin
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.Compiler.Quad;
5   
6   import joeq.Compiler.Quad.Operand.RegisterOperand;
7   import joeq.Interpreter.QuadInterpreter;
8   import joeq.Main.jq;
9   import joeq.Runtime.Unsafe;
10  
11  /*
12   * @author  Michael Martin <mcmartin@stanford.edu>
13   * @version $Id: Delegates.java 1457 2004-03-09 22:38:33Z jwhaley $
14   */
15  class Delegates {
16      static class Op implements Operator.Delegate {
17          public void interpretGetThreadBlock(Operator.Special op, Quad q, QuadInterpreter s) {
18              if (jq.RunningNative)
19                  s.putReg_A(((RegisterOperand)Operator.Special.getOp1(q)).getRegister(), Unsafe.getThreadBlock());
20          }
21          public void interpretSetThreadBlock(Operator.Special op, Quad q, QuadInterpreter s) {
22              joeq.Scheduler.jq_Thread o = (joeq.Scheduler.jq_Thread)Operator.getObjectOpValue(Operator.Special.getOp2(q), s);
23              if (jq.RunningNative)
24                  Unsafe.setThreadBlock(o);
25          }
26          public void interpretMonitorEnter(Operator.Monitor op, Quad q, QuadInterpreter s) {
27              Object o = Operator.getObjectOpValue(Operator.Monitor.getSrc(q), s);
28              if (jq.RunningNative)
29                  joeq.Runtime.Monitor.monitorenter(o);
30          }
31          public void interpretMonitorExit(Operator.Monitor op, Quad q, QuadInterpreter s) {
32              Object o = Operator.getObjectOpValue(Operator.Monitor.getSrc(q), s);
33              if (jq.RunningNative)
34                  joeq.Runtime.Monitor.monitorexit(o);
35          }
36      }
37  }